/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-11-14
 * Time: 14:53
 */
class Animal{
    public String name;
    public  int age;
    public void eat(){
        System.out.println(name+"正在吃饭");
    }
}
class Dog extends Animal{
    public void wangwang(){
        System.out.println(name+"正在汪汪叫");
    }
    @Override
    public void eat(){
        System.out.println(name+"正在吃狗粮");
    }
}
class Bird extends Animal{
    public String wing;
    public void fly(){
        System.out.println(name+"正在飞");

    }
   @Override
    public void eat(){
        System.out.println(name+"正在吃鸟粮");
    }
}
class Cat extends Animal{
    public void miaomiao(){
        System.out.println(name+"正在喵喵叫");
    }

    @Override
    public void eat() {
        System.out.println(name+"正在吃猫粮");
    }
}

public class TestDemo2 {
    public static void main(String[] args) {

    }
    public static void main2(String[] args) {
        Animal animal=new Dog();
        Dog dog=(Dog)animal;
        dog.name="贝贝";
        dog.eat();
        dog.wangwang();
        System.out.println("=======");


        if(animal instanceof  Cat) {
            Cat  cat=(Cat)animal;
            cat.miaomiao();
        }


    }
    public static void mai1(String[] args) {
        Animal animal1=new Dog();
        animal1.name="贝贝";
        animal1.eat();
        Animal animal2=new Bird();
        animal2.name="喳喳";
        animal2.eat();
        Animal  animal3=new Cat();
        animal3.name="小花";
        animal3.eat();


    }


}
